<?php
/**
 * Created by PhpStorm.
 * User: 快定
 * Date: 2021/10/27
 * Time: 16:35
 */

namespace App\Models\Traits;


trait But
{
    public function editBut(String $route)
    {
        if (config('rbac.super') != auth()->user()->username && !in_array($route, request()->auths))
            return '';
        return '<a href=' . route($route, $this) . ' >修改</a>';
    }

    public function delBut(String $route)
    {
        if (config('rbac.super') != auth()->user()->username && !in_array($route, request()->auths))
            return '';
        return '<a href=' . route($route, $this) . ' onclick="return del(event,this)" >删除</a>';
    }

    public function addBut(String $route)
    {
        if (config('rbac.super') != auth()->user()->username && !in_array($route, request()->auths))
            return '';
        return '<a href=' . route($route, $this) . ' class="btn btn-primary radius">新增</a>';
    }
}